package com.guomao.demog;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

class UserServiceInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        System.out.println("执行方法前");
        Object result = null;
        try {
            result = proxy.invokeSuper(obj, args);
        } catch (Throwable e) {
            System.out.println();
            throw new RuntimeException(e);
        } finally {
            System.out.println();
        }
        System.out.println("执行方法后");
        return result;
    }
}